package com.whut.report;

import com.alibaba.fastjson.JSONArray;
import com.whut.model.ContractCheckTask;
import com.whut.model.Profiles;
import com.whut.model.UrlProperties;
import com.whut.parMapper.ParProblemCollectDetailMapper;
import com.whut.parMapper.ParProblemDescriptionMapper;
import com.whut.parMapper.ParSystemMapper;
import com.whut.parMapper.utils.MapperUtils;
import com.whut.service.impl.ReportServiceImpl;
import com.whut.utils.FileUtil;
import com.whut.utils.MDoc;
import com.whut.v_model.ProblemCollectDetail;

import javax.annotation.Resource;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

public class RectificationNoticeCreateReport {
    @Resource
    private UrlProperties urlProperties;
    private ParSystemMapper parSystemMapper;
    private ParProblemDescriptionMapper parProblemDescriptionMapper;
    private ParProblemCollectDetailMapper parProblemCollectDetailMapper;
    private ReportServiceImpl reportServiceImpl;
    private Profiles profiles;
    private MapperUtils mapperUtils;

    private int checkId;
    private int projectId;
    private boolean isNew;
    public static final int WIDTH = 718;
    public static final int HEIGHT = 468;
    public RectificationNoticeCreateReport(ParSystemMapper parSystemMapper,
                                           ParProblemDescriptionMapper parProblemDescriptionMapper,
                                           ParProblemCollectDetailMapper parProblemCollectDetailMapper,
                                           ReportServiceImpl reportServiceImpl,
                                           MapperUtils mapperUtils,
                                           UrlProperties urlProperties,
                                           Profiles profiles
    ) {
        this.parSystemMapper = parSystemMapper;
        this.parProblemDescriptionMapper = parProblemDescriptionMapper;
        this.parProblemCollectDetailMapper = parProblemCollectDetailMapper;
        this.reportServiceImpl = reportServiceImpl;
        this.mapperUtils=mapperUtils;
        this.urlProperties=urlProperties;
        this.urlProperties=urlProperties;
        this.profiles=profiles;

    }
    public String rectificationNoticeCreate(int checkId, boolean isNew) throws UnsupportedEncodingException
    {
        HashMap<String, Object> dataMap = new HashMap<>();
        List<ContractCheckTask> getBaseData = mapperUtils.getContractchecktaskMapper().getBaseData(checkId);
        //System.out.println("getBaseData:"+getBaseData);
        String finishTime = getBaseData.get(0).getFinishTime();
        String year = finishTime.substring(0, 4);
        String month = finishTime.substring(5, 7);
        String date = finishTime.substring(8, 10);
        /*Date d = new SimpleDateFormat("yyyy-MM-dd").parse(finishTime);
        SimpleDateFormat Dyear = new SimpleDateFormat("yyyy");
        SimpleDateFormat Dmonth = new SimpleDateFormat("MM");
        SimpleDateFormat Ddate = new SimpleDateFormat("dd");
        String year = Dyear.format(d);
        String month = Dmonth.format(d);
        String date = Ddate.format(d);*/
        dataMap.put("finishMonth", month + "月份");
        dataMap.put("finishTime", year + "年" + month + "月" + date + "日");
        dataMap.put("projectName", getBaseData.get(0).getProjectName());
        dataMap.put("xfUnit", "");
        dataMap.put("receiveUnit", "");
        dataMap.put("ruLeader", "");
        /*List<GroupMemberDetail> getGroupMem = groupMemberDetailMapper.getGroupMemByCheckID(checkId);*/

        //System.out.println("getGroupMem:" + getGroupMem);

        /*int temp = 0;
        String str = "";
        for (GroupMemberDetail gmd: getGroupMem) {
            temp++;
            if(!gmd.getUserName().equals("")){
                str += gmd.getUserName()+",";
                if(getGroupMem.size() == temp){
                    str += gmd.getUserName();
                }
            }
        }
        dataMap.put("checkMember", str.toString());*/

        //forthlist + sevenlist循环
        //String pName4 = "";
        List<String> pName4 = new ArrayList<>();
        List<ProblemCollectDetail> forthLevel = parProblemCollectDetailMapper.getForthLevelByCheckId(checkId);

        for (ProblemCollectDetail pcd : forthLevel) {
            if (!pName4.contains(pcd.getpName4())) {
                pName4.add(pcd.getpName4());
            }
        }
        //tem.out.println("pName4:"+pName4);


        List<Object> forthLevelList = new ArrayList<>();
        for (int i = 0; i < pName4.size(); i++) {
            String s = "";
            String p = "";
            String storeS = "";
            String storeP = "";
            HashMap<String, Object> forthLevelMap = new HashMap<>();
            if (!pName4.get(i).equals("文明施工")) {
                List<ProblemCollectDetail> sevenLevel = parProblemCollectDetailMapper.getProDescByCheckIdAndpName4UnderSecur(checkId, pName4.get(i));
                List<Object> seventhLevelList = new ArrayList<>();
                List<Object> flPicList = new ArrayList<>();
                forthLevelMap.put("forthName", pName4.get(i));
                //System.out.println("pName4:"+pName4.get(i));

                List<String> picNameList = new ArrayList<>();
                int temp1 = 0;
                List<Integer> jaSize = new ArrayList<>();
                for (ProblemCollectDetail pcd1 : sevenLevel) {
                    temp1++;
                    HashMap<String, Object> seventhLevelMap = new HashMap<>();
                    //System.out.println("sevenLevel.size:" + sevenLevel.size());

                    if (!pcd1.getRemark().equals("")) {
                        seventhLevelMap.put("problemDescription", pcd1.getCheckPart() + ":" + pcd1.getRemark());
                        seventhLevelList.add(seventhLevelMap);
                        // System.out.println("seventhLevelList:" + seventhLevelList);
                    } else {
                        seventhLevelMap.put("problemDescription", pcd1.getCheckPart() + ":" + pcd1.getProblemDescription());
                        seventhLevelList.add(seventhLevelMap);
                        // System.out.println("seventhLevelList:" + seventhLevelList);
                    }

                    //获取picName(!pName.equals("文明施工"))
                    String picName = pcd1.getPicName();
                    JSONArray ja = JSONArray.parseArray(picName);
                    jaSize.add(ja.size());
                    //图片文字循环
                    for (int u = 0; u < ja.size(); u++) {
                        //  System.out.println("u:"+u);
                        //  System.out.println("storeS:"+storeS);
                        // System.out.println("storeP:"+storeP);
                        HashMap<String, Object> flPicMap = new HashMap<>();
                        if (!pcd1.getRemark().equals("")) {
                            if (!storeS.equals("") && !storeP.equals("")) {
                                if (u % 2 != 0) {
                                    if (pcd1.getPicPath().equals("")) {
                                        //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                        s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                    } else {
                                        s = MDoc.getImageStr(pcd1.getPicPath() + ja.get(u));
                                        //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png");
                                    }
                                    p = pcd1.getCheckPart() + ":" + pcd1.getRemark();
                                } else {
                                    if (pcd1.getPicPath().equals("")) {
                                        //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                        String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                        flPicMap.put("pic2", s1);
                                    } else {
                                        flPicMap.put("pic2", MDoc.getImageStr(pcd1.getPicPath() + ja.get(u)));
                                        //flPicMap.put("pic2", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png"));
                                    }
                                    flPicMap.put("pictureDescription2", pcd1.getCheckPart() + ":" + pcd1.getRemark());
                                    flPicMap.put("pictureDescription1", p);
                                    flPicMap.put("pic1", s);
                                    flPicList.add(flPicMap);
                                    // System.out.println("PDNULLp:"+p);
                                    // System.out.println("PDNULLs:"+s);
                                }
                            } else {
                                if (u % 2 == 0) {
                                    if (pcd1.getPicPath().equals("")) {
                                        //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                        s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                    } else {
                                        s = MDoc.getImageStr(pcd1.getPicPath() + ja.get(u));
                                        //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png");
                                    }
                                    p = pcd1.getCheckPart() + ":" + pcd1.getRemark();
                                } else {
                                    if (pcd1.getPicPath().equals("")) {
                                        //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                        String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                        flPicMap.put("pic2", s1);
                                    } else {
                                        flPicMap.put("pic2", MDoc.getImageStr(pcd1.getPicPath() + ja.get(u)));
                                        //flPicMap.put("pic2", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png"));
                                    }
                                    flPicMap.put("pictureDescription2", pcd1.getCheckPart() + ":" + pcd1.getRemark());
                                    flPicMap.put("pictureDescription1", p);
                                    flPicMap.put("pic1", s);
                                    flPicList.add(flPicMap);
                                    // System.out.println("PDNULLp:"+p);
                                    //  System.out.println("PDNULLs:"+s);
                                }
                            }
                        } else {
                            if (!storeS.equals("") && !storeP.equals("")) {
                                if (u % 2 != 0) {
                                    if (pcd1.getPicPath().equals("")) {
                                        //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                        s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                    } else {
                                        s = MDoc.getImageStr(pcd1.getPicPath() + ja.get(u));
                                        //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png");
                                    }
                                    p = pcd1.getCheckPart() + ":" + pcd1.getProblemDescription();
                                } else {
                                    if (pcd1.getPicPath().equals("")) {
                                        //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                        String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                        flPicMap.put("pic2", s1);
                                    } else {
                                        flPicMap.put("pic2", MDoc.getImageStr(pcd1.getPicPath() + ja.get(u)));
                                        //flPicMap.put("pic2", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png"));
                                    }
                                    flPicMap.put("pictureDescription2", pcd1.getCheckPart() + ":" + pcd1.getProblemDescription());
                                    flPicMap.put("pictureDescription1", p);
                                    flPicMap.put("pic1", s);
                                    flPicList.add(flPicMap);
                                    // System.out.println("sPnullP:"+p);
                                    //  System.out.println("sSnullS:"+s);
                                }
                            } else {
                                if (u % 2 == 0) {
                                    if (pcd1.getPicPath().equals("")) {
                                        //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                        s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                    } else {
                                        s = MDoc.getImageStr(pcd1.getPicPath() + ja.get(u));
                                        //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png");
                                    }
                                    p = pcd1.getCheckPart() + ":" + pcd1.getProblemDescription();
                                } else {
                                    if (pcd1.getPicPath().equals("")) {
                                        //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                        String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                        flPicMap.put("pic2", s1);
                                    } else {
                                        //flPicMap.put("pic2", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png"));
                                        flPicMap.put("pic2", MDoc.getImageStr(pcd1.getPicPath() + ja.get(u)));
                                    }
                                    flPicMap.put("pictureDescription2", pcd1.getCheckPart() + ":" + pcd1.getProblemDescription());
                                    flPicMap.put("pictureDescription1", p);
                                    flPicMap.put("pic1", s);
                                    flPicList.add(flPicMap);
                                    // System.out.println("sPnullP:"+p);
                                    // System.out.println("sSnullS:"+s);
                                }
                            }
                        }

                        int size = 0;
                        for (int x : jaSize) {
                            size += x;
                        }
                        // System.out.println("size:"+size);
                        if (size % 2 != 0 && u == (ja.size() - 1) && temp1 == sevenLevel.size()) {
                            //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                            String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                            flPicMap.put("pic2", s1);
                            flPicMap.put("pictureDescription2", "");
                            flPicMap.put("pic1", s);
                            flPicMap.put("pictureDescription1", p);
                            flPicList.add(flPicMap);
                        } else if (u == (ja.size() - 1) && temp1 != sevenLevel.size() && size % 2 != 0) {
                            storeS = s;
                            storeP = p;
                        } else if (u == (ja.size() - 1) && temp1 != sevenLevel.size() && size % 2 == 0) {
                            storeP = "";
                            storeS = "";
                        }
                    } // for ja

                }
                forthLevelMap.put("flPicList", flPicList);
                forthLevelMap.put("seventhLevelList", seventhLevelList);
                forthLevelList.add(forthLevelMap);

                // System.out.println("seventhLevelList:"+seventhLevelList);
                //System.out.println("flPicList:"+flPicList);
                //System.out.println("forthLevelList:"+forthLevelList);
            }
        }
        dataMap.put("forthLevelList", forthLevelList);

        String s = "";
        String p = "";
        String storeS = "";
        String storeP = "";
        int temp2 = 0;
        List<Integer> jaSize = new ArrayList<>();
        List<ProblemCollectDetail> sevenLevel = parProblemCollectDetailMapper.getProDescByCheckIdAndpName4(checkId, "文明施工");
        List<Object> wmsgList = new ArrayList<>();
        List<Object> wmsgPicList = new ArrayList<>();
        if (sevenLevel.size() == 0) {
            HashMap<String, Object> wmsgMap = new HashMap<>();
            wmsgMap.put("problemDescription", "");
            wmsgList.add(wmsgMap);
            HashMap<String, Object> wmsgPicMap = new HashMap<>();
            wmsgPicMap.put("pic2", "");
            wmsgPicMap.put("pictureDescription2", "");
            wmsgPicMap.put("pic1", "");
            wmsgPicMap.put("pictureDescription1", "");
            wmsgPicList.add(wmsgPicMap);
            dataMap.put("wmsgPicList", wmsgPicList);
            dataMap.put("wmsgList", wmsgList);
        } else {
            for (ProblemCollectDetail pcd1 : sevenLevel) {
                HashMap<String, Object> wmsgMap = new HashMap<>();
                temp2++;
                if (!pcd1.getRemark().equals("")) {
                    wmsgMap.put("problemDescription", pcd1.getCheckPart() + ":" + pcd1.getRemark());
                    wmsgList.add(wmsgMap);
                } else {
                    wmsgMap.put("problemDescription", pcd1.getCheckPart() + ":" + pcd1.getProblemDescription());
                    wmsgList.add(wmsgMap);
                }

                //获取picName(pName4.equals("文明施工"))
                String picName = pcd1.getPicName();
                JSONArray ja = JSONArray.parseArray(picName);
                jaSize.add(ja.size());
                for (int u = 0; u < ja.size(); u++) {
                    HashMap<String, Object> wmsgPicMap = new HashMap<>();
                    if (!pcd1.getRemark().equals("")) {
                        if (!storeP.equals("") && !storeS.equals("")) {
                            if (u % 2 != 0) {
                                if (pcd1.getPicPath().equals("")) {
                                    //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                    s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                } else {
                                    s = MDoc.getImageStr(pcd1.getPicPath() + ja.get(u));
                                    //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png");
                                }
                                p = pcd1.getCheckPart() + ":" + pcd1.getRemark();
                            } else {
                                if (pcd1.getPicPath().equals("")) {
                                    //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                    String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                    wmsgPicMap.put("pic2", s1);
                                } else {
                                    wmsgPicMap.put("pic2", MDoc.getImageStr(pcd1.getPicPath() + ja.get(u)));
                                    //wmsgPicMap.put("pic2", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png")) ;
                                }
                                wmsgPicMap.put("pictureDescription2", pcd1.getCheckPart() + ":" + pcd1.getRemark());
                                wmsgPicMap.put("pictureDescription1", p);
                                wmsgPicMap.put("pic1", s);
                                wmsgPicList.add(wmsgPicMap);
                            }
                        } else {
                            if (u % 2 == 0) {
                                if (pcd1.getPicPath().equals("")) {
                                    //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                    s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                } else {
                                    s = MDoc.getImageStr(pcd1.getPicPath() + ja.get(u));
                                    //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png");
                                }
                                p = pcd1.getCheckPart() + ":" + pcd1.getRemark();
                            } else {
                                if (pcd1.getPicPath().equals("")) {
                                    //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                    String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                    wmsgPicMap.put("pic2", s1);
                                } else {
                                    wmsgPicMap.put("pic2", MDoc.getImageStr(pcd1.getPicPath() + ja.get(u)));
                                    //wmsgPicMap.put("pic2", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png")) ;
                                }
                                wmsgPicMap.put("pictureDescription2", pcd1.getCheckPart() + ":" + pcd1.getRemark());
                                wmsgPicMap.put("pictureDescription1", p);
                                wmsgPicMap.put("pic1", s);
                                wmsgPicList.add(wmsgPicMap);
                            }
                        }
                    } else {
                        if (!storeP.equals("") && !storeS.equals("")) {
                            if (u % 2 != 0) {
                                if (pcd1.getPicPath().equals("")) {
                                    //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                    s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                } else {
                                    s = MDoc.getImageStr(pcd1.getPicPath() + ja.get(u));
                                    //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png");
                                }
                                p = pcd1.getCheckPart() + ":" + pcd1.getProblemDescription();
                            } else {
                                if (pcd1.getPicPath().equals("")) {
                                    //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                    String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                    wmsgPicMap.put("pic2", s1);
                                } else {
                                    wmsgPicMap.put("pic2", MDoc.getImageStr(pcd1.getPicPath() + ja.get(u)));
                                    //wmsgPicMap.put("pic2", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png")) ;
                                }
                                wmsgPicMap.put("pictureDescription2", pcd1.getCheckPart() + ":" + pcd1.getProblemDescription());
                                wmsgPicMap.put("pictureDescription1", p);
                                wmsgPicMap.put("pic1", s);
                                wmsgPicList.add(wmsgPicMap);
                            }
                        } else {
                            if (u % 2 == 0) {
                                if (pcd1.getPicPath().equals("")) {
                                    //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                    s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                } else {
                                    s = MDoc.getImageStr(pcd1.getPicPath() + ja.get(u));
                                    //s =MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png");
                                }
                                p = pcd1.getCheckPart() + ":" + pcd1.getProblemDescription();
                            } else {
                                if (pcd1.getPicPath().equals("")) {
                                    //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                    String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                    wmsgPicMap.put("pic2", s1);
                                } else {
                                    wmsgPicMap.put("pic2", MDoc.getImageStr(pcd1.getPicPath() + ja.get(u)));
                                    //wmsgPicMap.put("pic2", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png")) ;
                                }
                                wmsgPicMap.put("pictureDescription2", pcd1.getCheckPart() + ":" + pcd1.getProblemDescription());
                                wmsgPicMap.put("pictureDescription1", p);
                                wmsgPicMap.put("pic1", s);
                                wmsgPicList.add(wmsgPicMap);
                            }
                        }
                    }

                    int size = 0;
                    for (int x : jaSize) {
                        size += x;
                    }

                    if (size % 2 != 0 && u == (ja.size() - 1) && temp2 == sevenLevel.size()) {
                        //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                        String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                        wmsgPicMap.put("pic2", s1);
                        wmsgPicMap.put("pictureDescription2", "");
                        wmsgPicMap.put("pic1", s);
                        wmsgPicMap.put("pictureDescription1", p);
                        wmsgPicList.add(wmsgPicMap);
                    } else if (u == (ja.size() - 1) && temp2 != sevenLevel.size() && size % 2 != 0) {
                        storeP = p;
                        storeS = s;
                    } else if (u == (ja.size() - 1) && temp2 != sevenLevel.size() && size % 2 == 0) {
                        storeP = "";
                        storeS = "";
                    }
                }
                dataMap.put("wmsgPicList", wmsgPicList);
                //System.out.println("wmsgPicList:"+wmsgPicList);
            }
            dataMap.put("wmsgList", wmsgList);
        }


        //System.out.println("wmsgList:"+wmsgList);


        //所有管理行为中施工单位安全管理内容
        List<Object> sgList = new ArrayList<>();
        List<ProblemCollectDetail> getSgList = parProblemCollectDetailMapper.getSgList(checkId);
        for (ProblemCollectDetail pcd : getSgList) {
            HashMap<String, Object> sgMap = new HashMap<>();
            if (pcd.getRemark().equals("")) {
                sgMap.put("problemDescription", pcd.getCheckPart() + ":" + pcd.getProblemDescription());
            } else {
                sgMap.put("problemDescription", pcd.getCheckPart() + ":" + pcd.getRemark());
            }
            sgList.add(sgMap);
        }
        dataMap.put("sgList", sgList);

        //所有管理行为中监理单位安全管理内容
        List<Object> jlList = new ArrayList<>();
        List<ProblemCollectDetail> getJlList = parProblemCollectDetailMapper.getJlList(checkId);
        for (ProblemCollectDetail pcd : getJlList) {
            HashMap<String, Object> jlMap = new HashMap<>();
            if (pcd.getRemark().equals("")) {
                jlMap.put("problemDescription", pcd.getCheckPart() + ":" + pcd.getProblemDescription());
            } else {
                jlMap.put("problemDescription", pcd.getCheckPart() + ":" + pcd.getRemark());
            }
            jlList.add(jlMap);
        }
        dataMap.put("jlList", jlList);
        // System.out.println("dataMap:"+ dataMap);

        Date date1 = new Date();
        DateFormat d1 = new SimpleDateFormat("yyyyMMddhhmmss");
        String fileName = d1.format(date1);

        MDoc mdoc = new MDoc();
        String path = FileUtil.getServerFolderPath();
        File f1 = new File(path, "doc");
        if (!f1.exists()) {
            f1.mkdirs();
        }

        mdoc.createDoc(dataMap, path + "\\doc\\" + getBaseData.get(0).getProjectName().replace('#', '号') + "安全整改通知单" + dataMap.get("fileDate") + ".doc", "ftl\\zgtzd.ftl");
        //MDoc.docToDocx("D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + getBaseData.get(0).getProjectName().replace('#','号')+"安全整改通知单"+dataMap.get("fileDate") + ".doc", "D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + getBaseData.get(0).getProjectName().replace('#','号')+"安全整改通知单"+dataMap.get("fileDate") +  ".doc");
        String result = urlProperties.getAddress() + "/doc/" + getBaseData.get(0).getProjectName().replace('#', '号') + "安全整改通知单" + dataMap.get("fileDate") + ".doc";
        /*Date date7 = new Date();
        DateFormat d1 = new SimpleDateFormat("yyyyMMddhhmmss");
        String dataMap.get("fileDate") = d1.format(date7) ;
        MDoc mdoc = new MDoc();
        mdoc.createDoc(dataMap, "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + dataMap.get("fileDate") + ".doc", "ftl\\zgtzd.ftl");
        MDoc.docToDocx("E:\\tencent_File\\1296928795\\FileRecv\\yirui" + dataMap.get("fileDate") + ".doc", "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + dataMap.get("fileDate") + ".doc");
        String result = "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + dataMap.get("fileDate") + ".doc";*/
        return result;
    }
}
